Thorium Server

Annotations

HTTP methods supported can be found here.

To make a parameter as part of the query string, simply leave out the parameter in the path pattern. 

For example, our previous "sayHello" method can be made to accept "name" parameter in its query string by changing it like so:

@Get("/sayHello") // previously /sayHello/:name
def sayHello(@Param name: String) = Action: request =>
  s"Hello $name"

Do take note that once you remove the parameter from the path pattern, if you call this endpoint without passing in a name, it will return a Bad Request 400. In order to avoid this, define a Default Param.

@Get("/sayHello")
def sayHello(@Param @Default("") name: String) = Action: request =>
  s"Hello $name"
Read more about how Armeria handles query strings here.


Last modified on 22/11/2023, 3:38 pm